'''
'import_export',   # 文件导入导出
功能
'''
from import_export.fields import Field
from import_export import resources
from .models import Config

class ConfigResource(resources.ModelResource):
    # 字段名中文处理
    id = Field(attribute='id', column_name='序号')
    no = Field(attribute='no', column_name='编号')
    name = Field(attribute='name', column_name=Config.name.field.verbose_name)

    class Meta:
        model = Config
        # 导入字段设定/注释表示全部字段导入
        fields = ('id', 'no', 'name')
        # 导出字段设定/注释表示全部字段导出
        export_order = ('no', 'name')
        # 排除主键字段id
        exclude = ['id']
        # 设置主键字段/ 注释采用默认
        import_id_fields = ['name']

